package buco.jsonrpc;

import java.io.IOException;
import java.io.Writer;

import org.json.simple.*;

import buco.core.api.*;

public class RequirementConverter implements JSONStreamAware {

	private Requirement req; 
	
	public RequirementConverter(Requirement req) {
		this.req = req; 
	}
	
	@Override
	public void writeJSONString(Writer wr) throws IOException {
		if(req instanceof ImportPackageRequirement) {
			ImportPackageRequirement ipr = (ImportPackageRequirement) req; 
			new ImportPackageRequirementConverter(ipr).writeJSONString(wr); 
		} else if (req instanceof RequireBundleRequirement) {
			RequireBundleRequirement rbr = (RequireBundleRequirement) req; 
			new RequireBundleRequirementConverter(rbr).writeJSONString(wr);
		}
	}

}
